#include <time.h>
#include <iostream>
#include <vector>
#include <atomic>
#include <thread>

using namespace std;

void thread_func(int& n)
{
    for (int i = 0; i < 100; i++)
    {
        std::this_thread::sleep_for(std::chrono::milliseconds(1));
        ++n;
    }
}

void thread_funcx(atomic_int& n)
{
    for (int i = 0; i < 100; i++)
    {
        std::this_thread::sleep_for(std::chrono::milliseconds(1));
        ++n;
    }
}

int main(int argc, char* argv)
{
    atomic_int atomicI = 0;
    int iTest = 0;
    thread t1(thread_funcx, std::ref(atomicI));
    thread t2(thread_funcx, std::ref(atomicI));
    t1.join();
    t2.join();
    cout << atomicI << endl;
    return 0;
}
